'''
Created on Jan 4, 2012

@author: onetera
'''
from PyQt4 import QtCore , QtGui
from lib.papyDB import papyDB , tableInfo
from lib import globalVar
from lib import papyDBTable
from shotAssembler_UI import shotAssembler_UI
from insertItem import insertItemDiag
from lib.assets import Asset
from lib.customUI import customUI
import os
import pickle
papyDB = papyDB()


class assmHistoryModel:
    def __init__(self , prj,seq,shot , dept):
        self.shot = shot        
        self.dept = dept
        self.prjID = papyDBTable.PROJECT.search( 'prjID' , prjCodeName = prj  )
        self.seqID = papyDBTable.SEQUENCES.search( 'seqID' , prjID = self.prjID , seqName = seq )          
#        self.shotID = papyDBTable.SHOT.search( 'shotID' , seqID = self.seqID  , shotName =  self.shot )
                 
        self.shotID = papyDBTable.SHOT.search( 'shotID' , seqID =  self.seqID , shotName = self.shot  )

        
    def getAssmHistory(self):
        if self.dept == 'Animation':
            theAnimID =papyDBTable.ANIM.search( 'animID' , shotID  = self.shotID )
#            print theAnimID
            query = 'select animAssmID , userID , assmTableModel from ANIM_ASSEMBLE where animID = %s' % theAnimID
            result = papyDB.getFetch(  query  )
            return result


#papyDB.getFetch(  "select shotID from SHOT where seqID = 1 and shotName = 'sh014'"  )
aa = assmHistoryModel( 'cap' , 'sky' , 'sh104' , 'Animation' )


print aa.getAssmHistory()




